class Solution:
    def isAnagram_my(self, s, t):
        # 统计字符 O(n)
        s_dict = {}
        t_dict = {}
        for word in s:
            s_dict[word] = s_dict.get(word, 0) + 1
        for word in t:
            t_dict[word] = t_dict.get(word, 0) + 1

        return s_dict == t_dict

    def isAnagram(self, s, t):
        # 排序方式 O(nlogn)
        return sorted(list(s)) == sorted(list(t))


s = "anagram"
t = "nagaram"

sl = Solution()
print(sl.isAnagram(s, t))
